package com.allwees.core.common.util;

import com.allwees.core.common.exception.BaseException;
import org.apache.commons.lang3.EnumUtils;

/**
 * Enum Util
 *
 * @author yangylsky
 * @since 2019-12-11
 *
 */
public class EnumUtil {
	@SuppressWarnings("unchecked")
	public static <E extends Enum<E>> E getEnum(String enumClassName, String name) {
		try {
			return EnumUtils.getEnum((Class<E>) Class.forName(enumClassName), name);
		} catch(ClassNotFoundException e) {
			throw new BaseException("Enum[" + enumClassName + ": " + name + "]不存在");
		}
	}
}
